package com.hyperfix.simulator.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hyperfix.models.simulator.pojos.ScheduleSetting;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author JiangChunYu
 * 2024/3/12
 */
@Mapper
public interface SysJobMapper extends BaseMapper<ScheduleSetting> {
    @Update("update schedule_setting set cron_expression = #{cron} where pipeline = #{pipelineId}")
    int updateCycleByPipelineId(@Param("pipelineId") Integer pipelineId, @Param("cron") String cron);

    @Update("update schedule_setting set job_status = #{status} where pipeline = #{pipelineId}")
    int updateStatusByPipelineId(@Param("pipelineId") Integer pipelineId, @Param("status") Integer status);

    List<ScheduleSetting> selectAll();

    ScheduleSetting selectOneByPipelineId(@Param("pipelineId") Integer pipelineId);
}
